﻿@using PersonalWebSite.Common
@{
    ViewBag.Title = "Hintea Dan Alexandru - Photo Albums";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<div id="UniverseHolderWrapper">
    <div class="hdunv-fixture"> 
        <div data-hdunv_type="Universe" data-hdunv_x="0" data-hdunv_y="0" data-hdunv_w="1000" data-hdunv_h="350" data-hdunv_name="hD Universe" data-starfield_enabled="false" data-shootingstar_enabled="false">
            <div class="hdunv-content"></div>

            <div data-hdunv_type="Galaxy" data-hdunv_depth="0" data-hdunv_x="0" data-hdunv_y="0" data-hdunv_w="50" data-hdunv_h="350" data-hdunv_name="Header">
                <div data-hdunv_type="SolarSystem" data-hdunv_speed="0" data-hdunv_direction="cw" data-hdunv_x="0" data-hdunv_y="0" data-hdunv_w="0" data-hdunv_h="0" data-hdunv_name="MainSection Top">
                    <div class="hdunv-content">
                        @{Html.RenderAction("Button", "Tiles", new { IconName = "Home", Tip = "Home", NavigateUrl = Url.Action("Index", "Home") });}
                    </div>
                </div>
            </div>

            <!-- ko foreach: { data: AlbumFeed.Items} -->
            <div data-hdunv_type="Galaxy" data-hdunv_depth="0" data-hdunv_x="0" data-hdunv_y="0" data-hdunv_w="350" data-hdunv_h="350" data-hdunv_name="Header">
                <div data-hdunv_type="SolarSystem" data-hdunv_speed="0" data-hdunv_direction="cw" data-hdunv_x="0" data-hdunv_y="0" data-hdunv_w="0" data-hdunv_h="0" data-hdunv_name="MainSection Top">
                    <div class="hdunv-content">
                        @{Html.RenderAction("PhotoAlbum", "Tiles");}
                    </div>
                </div>
            </div>
            <!-- /ko -->

        </div>
    </div>
</div>

<script type="text/javascript">

    $(window).resize(function () {
        $("#UniverseHolderWrapper").css("height", $(window).outerHeight());
    });
    $("#UniverseHolderWrapper").css("height", $(window).outerHeight());

    var PageViewModel = {
        AlbumFeed: {Items:[]}
    };

    var fetchPhotoAlbumsAjaxIconId = -1;
    _hD.push(function () {
        fetchPhotoAlbumsAjaxIconId = AjaxIconToggle(true);
        $.ajax('@Url.Action("FetchPhotoAlbums", "Activity")', {
            complete: function (jqXHR, textStatus) {
                if (AjaxIconToggle)
                    AjaxIconToggle(false, fetchPhotoAlbumsAjaxIconId);
                else
                    _hD.push(function () { AjaxIconToggle(false, fetchPhotoAlbumsAjaxIconId); });
            },
            success: function (data, textStatus, jqXHR) {
                if (data)
                    PageViewModel.AlbumFeed = data;
                InitAlbumTiles();
            },
            error: function (jqXHR, textStatus, errorThrown) {
                NotifierShow('Some error occured while trying to retrieve the photo albums. I\'m very sorry for that, please try again by refreshing the page.', 'This page depends on some external services like Google\'s Picasa Web Albums Service. It may happen that these services are not available sometimes so again, sorry for the inconvenience and please try again to reload the page.');
            }
        });
    });

    function InitAlbumTiles() {
        ko.applyBindings(PageViewModel, $(".hdunv-fixture")[0]);

        var universe = new hDUnivSim("#UniverseHolderWrapper", new MetroStyleDrawer(), InPageHtmlFixture);
        universe.AlignHorizontal = Align.Horizontal.Left;
        universe.InitHtml();

        $(".PhotoAlbumTileMainWrapper").tooltipsy();

        InitMetroTilesColouringEffect();
    };
</script>
